<template>
  <div>
    登录
    <button type="submit" @click="loginHandler">登录</button>
    <button type="submit" @click="loginOut">退出</button>
  </div>
</template>

<script>
import {mapState,mapGetters,mapActions} from 'vuex';
export default {
  name: "login",
  meta: {
    title: "登录",
    requireAuth: false,
  },
  data() {
    return {
    
    };
  },
  computed: {
    ...mapGetters('login', {
      isLogined: 'isLoginedIn',
    }),
    ...mapState('login', ['token']),
    property() {
      return this.property;
    },
    property: {
      get() {
        return this.property;
      },
      set(val) {
        this.property = val;
      },
    },
  },
  created() {
    console.log(this.$route.query.id, this.$store.state.login,this.isLogined,this.token);
  },
  methods: {
    ...mapActions('login', {
      actLogin: 'login',
      actLoginOut:'loginOut'
    }),
    loginHandler() {
      this.actLogin({id:123}).then((res) => {
        let redirect = this.$route.query.redirect;
        if (redirect) this.$router.replace(redirect);
      });
      // this.$store.dispatch("login/login", { id: 123 }).then((res) => {
      //   let redirect = this.$route.query.redirect;
      //   if (redirect) this.$router.replace(redirect);
      // });
    },
    loginOut() {
      this.actLoginOut()
      // this.$store.dispatch("login/loginOut");
    },
  },
};
</script>
